package com.sws.web.controller.ry_rongyue.push;

import com.sws.common.core.domain.R;
import com.sws.push.config.AIConfig;
import com.sws.push.domain.AIDto;
import com.sws.push.service.AIAnalyzerService;
import com.sws.push.service.AIDialogue;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("push/AI")
class AIAnalyzerServiceController {

    @Autowired
    AIAnalyzerService aiAnalyzerService;

    @Autowired
    AIDialogue aIDialogue;



    /**
     * 生成用户画像
     * @param customerId
     * @return
     */
    @GetMapping("/analyze")
    R generation(Long customerId,String modelName) {
        return aiAnalyzerService.analyze(customerId,modelName)!=null?R.ok(aiAnalyzerService.analyze(customerId, modelName)):R.fail("该用户AI画像分析失败");
    }

    /**
     * AI对话

     * @return
     */
    @PostMapping("/chat")
    public Flux<String> AIChat(@RequestBody AIDto aiDto) {
        System.out.println(aiDto.getCustomerId()+aiDto.getContent());
        return aIDialogue.AIchat(aiDto);
    }

    /**
     * AI分析用户
     */
    @PostMapping("/analyzeListUsers")
    public Flux<String> AnalyzeListUsers(@RequestBody AIDto aiDto) {
        System.out.println(aiDto.getCustomerId());
        return aIDialogue.AnalyzeListUsers(aiDto);
    }





}